/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tencent.tendon.convert.json;

/**
 *
 * 例如：
 *
 * public class JsonBigIntegerListener extends JsonListener<BigInteger> {
 *
 * private static final JsonBigIntegerListener instance = new JsonBigIntegerListener();
 *
 * private JsonBigIntegerListener() {
 * }
 *
 * public static JsonBigIntegerListener getInstance() {
 * return instance;
 * }
 *
 * @Override
 * public void convertTo(JsonWriter out, BigInteger value) {
 * if (value == null) {
 * out.writeNull();
 * } else {
 * out.write(true, value.toString());
 * }
 * }
 *
 * @Override
 * public BigInteger convertFrom(char[] text, int start, int len) {
 * if (text == null) return null;
 * return new BigInteger(new String(text, start, len));
 * }
 *
 * @Override
 * public Class<BigInteger> getType() {
 * return BigInteger.class;
 * }
 * }
 *
 * @author nbzhang
 */
public abstract class JsonListener<T> implements JsonDecodable<T>, JsonEncodable<T>, JsonSimpleable {

    @Override
    public abstract void convertTo(final JsonWriter out, final T value);

    @Override
    public abstract T convertFrom(final JsonReader in);

    @Override
    public abstract Class<T> getType();

    @Override
    public final boolean isSimpled() {
        return true;
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName();
    }
}